<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/${sysEname}/include/common-base.jsp"%>
  <title>我的消息-${r'${titleName}'}</title>
</head>
<body class="hold-transition ${r'${sysUserColor}'} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/${sysEname}/top-user.jsp" %>
  <!-- top end -->

  <!-- left start -->
  <%@include file="/common/${sysEname}/left-user.jsp" %>
  <!-- left end-->

 <!-- main start -->
<div class="content-wrapper">
<div class="content">
  <div class="row">
    <!-- right start -->
    <div class="col-md-12 ">


          <!------搜索  start ------->
          <div class="box box-solid">
             <!--搜索title  start -->
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-search"></i> 消息搜索</h3>
              </div>
            <div class="box-body">
			  <form class="form-horizontal" role="form" id="myForm" action="javascript:void(0)" method="post">
	          <input type="hidden" name="pageName" value="trpNotice-list"/>
	          <input type="hidden" name="formName" value="searchForm"/>
	          <input type="hidden" name="orderBy"  value="trpNotice.create_time desc" />
	          <input type="hidden" name="trpNotice.w_sendCode" value="${r'${loginUser.userEname}'}'}"/>

				<div class="form-group col-sm-12">
					<label class="control-label col-sm-2"> 	消息标题：</label>
					<div class="col-sm-4">

						<input class="form-control clean" name="trpNotice.wl_noticeTitle"/>
					</div>
					<div class="form-group col-sm-6 text-center ">
				       <button type="button" class="btn btn-success" onclick="getMessage();"><i class="fa fa-search"></i> 查询</button> 
				       <button type="button" class="btn btn-warning" onclick="mytools.cleanData('#myForm');">重置 </button>
				   </div>
				</div>

			  </form>
            </div>
	     </div>
	     <!------- 搜索 end -------->


       <!------- 列表 start -------->
          <div class="box box-solid">
            <!--列表title  start -->
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-table"></i> 查询结果列表
                 </h3>
              </div>
            <!--列表title  end -->
              <div class="box-body">
                <table id="dataList" class="table table-bordered table-hover" >
                <thead>
              <tr>
                <th>消息标题</th>
                <th>发布时间</th>
                <th>来源</th>
                <th>状态</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody id="messageDiv">
            </tbody>
          </table>
          <center>
            <ul id="pageList">
            </ul>
          </center>
      </div>
    </div>
  </div>
</div>





	            <div id="div_layer_window" class="popbox">
					<dl>
					  <dt id="view_noticeTitle" style="padding:0 10px;text-align:left;background:#f5f5f5;font-weight:bold;"></dt>
					  <dd id="view_noticeContent" style="padding:0 20px;text-align:left;"></dd>
					</dl>
				</div>


   </div>


   <script type="text/template" id="messageDiv_template">
	  				<? for ( var i = 0; i < rows.length; i++) {?>
						<tr>
							<td><a href="#" onclick="openDiv('div_layer_window','<?=rows[i].noticeId?>')" ><?=rows[i].noticeTitle?></a></td>
							<td><?=getFormatDateByLong(rows[i].createTime)?></td>
							<td>平台通知</td>
							<td>
								<?if(rows[i].noticeStatus==0){?>
									<i class="fa fa-times text-danger"></i>
								<?}else{?>
									<i class="fa fa-check text-gray"></i>
								<?}?>
							</td>
							<td>
								<a href="#" onclick="openDiv('div_layer_window','<?=rows[i].noticeId?>')" >查看</a>|
								<a href="#" onclick="delNotice('<?=rows[i].noticeId?>')" >删除</a>
							</td>
						</tr>
					<?}?>
	</script>

   <script>
	var clickMenu = 'my-message';
    function openDiv(divID,noticeId) {
    	$.ajax({
			type:'get',
			url:common_info_url,
			async: false,
			data: {"pageName":"trpNotice-list","formName":"searchForm","trpNotice.w_noticeId":noticeId},
			dataType:'json',
			success:function(result){
				console.log(result);
				if(result){
		    	      $("#view_noticeTitle").html(result.noticeTitle);
					  $("#view_noticeContent").html("尊敬的用户您好！您参与的：<br/> &nbsp;&nbsp;&nbsp;项目名称：【"+result.bussRemark+"】<br/>&nbsp;&nbsp;&nbsp;项目编号：【"+result.bussCode+"】<br/>"+result.noticeContent);
					  layer.open({
					    type: 1,
					    title: '查看消息',
					    offset: '120px',
					    closeBtn: 1,
					    area: ['500px','400px'],
					    shadeClose: true,
					    content: $('#div_layer_window'),
					    end:function(){
					    	getMessage();
					    }
					 });
					editNotice(noticeId);
			     }
			}

	});
    }
	function delNotice(id){
		if(!window.confirm("您确认删除此信息消息吗？"))return;
		$.ajax({
			type:'post',
			url:common_submit_url,
			async:false,
			data:{"pageName":"trpNotice-list","formName":"delForm","trpNotice.w_noticeId":id},
			dataType:'json',
			success:function(myData){
				console.log(myData);
				var result = myData.flag;
	    		if(result=="T"){
	    			window.location.reload();
	    		}else{
	    			layer.alert("删除失败！");
	    		}
			}
	});

	}

	$(function(){
        //getMessage();
	})

	function getMessage(){
		var index_load = layer.load(1, {shade: false});
		var htmsName = "messageDiv";
		$.ajax({
			type:'get',
			url:common_list_url,
			//async: false,
			data: $('#myForm').serialize()+getCurrentPage(common_list_url+"?"+$('#myForm').serialize(),8),
			dataType:'json',
			success:function(result)	{
				console.log(result);
				layer.close(index_load);
					$('#'+htmsName).html("");
				  	var txt = baidu.template(htmsName+'_template',result);
				  	$("#"+htmsName).html(txt);
					  var option= {
							   ele:$("#pageList")[0],
							   total:result.total,
							   fn:getMessage,
							   url:common_list_url+"?"+$('#myForm').serialize()
						   }
					generatePages(option);
			}
		});
	}

	function editNotice(noticeId) {
		$.ajax({
			type:'post',
			url:common_submit_url,
			async: false,
			data: {"pageName":"trpNotice-list","formName":"editForm","trpNotice.w_noticeId":noticeId,"trpNotice.noticeStatus":"1"},
			dataType:'json',
			success:function(result){
				console.log(result);
			}

		});
	}
</script>

  </div>
 <!-- main end-->

</div>
  <!-- foot start -->
  <%@include file="/common/${sysEname}/foot-user.jsp" %>
  <!-- foot start -->
</body>

</html>


